﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ncp.Business;

namespace ncp.Web.Shop
{
    public partial class contact : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(contact), Page);
        }
        [AjaxPro.AjaxMethod]
        public string GetContact(string shop)
        {
            Dictionary<string, object> jsonResult = new Dictionary<string, object>();
            long shopId = 0;
            if (long.TryParse(shop, out shopId) && shopId > 103264587)
            {
                var dt = ClientInfoBll.GetClientById((shopId - 103264587).ToString(), CommonConst.DB_Name);
                if (dt.Rows.Count != 0)
                {
                    jsonResult.Add("isreload", true);
                    StringBuilder builder = new StringBuilder();
                    if (dt.Rows[0]["User_CellPhone"].ToString() != "")
                    {
                        builder.AppendFormat("<li><span>移动电话：</span> {0}</li>", dt.Rows[0]["User_CellPhone"]);
                    }
                    if (dt.Rows[0]["User_TelPhone"].ToString() != "")
                    {
                        builder.AppendFormat("<li><span>固定电话：</span> {0}</li>", dt.Rows[0]["User_TelPhone"]);
                    }
                    if (dt.Rows[0]["User_Email"].ToString() != "")
                    {
                        builder.AppendFormat("<li><span>电子邮箱：</span> {0}</li>", dt.Rows[0]["User_Email"]);
                    }
                    if (dt.Rows[0]["User_Contact"].ToString() != "")
                    {
                        builder.AppendFormat("<li><span>联系人：</span> {0}</li>", dt.Rows[0]["User_Contact"]);
                    }
                    if (dt.Rows[0]["User_Url"].ToString() != "")
                    {
                        builder.AppendFormat("<li><span>公司网址：</span> {0}</li>", dt.Rows[0]["User_Url"]);
                    }
                    if (dt.Rows[0]["User_Address"].ToString() != "")
                    {
                        builder.AppendFormat("<li><span>公司地址：</span> {0}</li>", dt.Rows[0]["User_Address"]);
                    }
                    jsonResult.Add("msg", builder.ToString());
                }
                else
                {
                    jsonResult.Add("isreload", false);
                    jsonResult.Add("msg", "0");
                }
            }
            else
            {
                jsonResult.Add("isreload", false);
                jsonResult.Add("msg", "0");
            }
            return "[" + JsonHelper.ObjectToJSON(jsonResult) + "]";
        }
    }
}
